package chaoyue.study.service.impl;

import chaoyue.study.bean.Depart;
import chaoyue.study.repository.DepartRepository;
import chaoyue.study.service.DepartService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartServiceImpl implements DepartService {
    @Resource
    private DepartRepository repository;

    @Override
    public void saveDepart(Depart depart) {
        repository.save(depart);
    }

    @Override
    public void removeDepart(Integer id) {
        repository.deleteById(id);
    }

    @Override
    public void modifyDepart(Depart depart) {
        repository.save(depart);
    }

    @Override
    public Depart getDepartById(Integer id) {
        return repository.getReferenceById(id);
    }

    @Override
    public List<Depart> listAllDeparts() {
        return repository.findAll();
    }
}
